//
//  manyPeopleListenCollectionReusableView.m
//  NewMusic
//
//  Created by dllo on 15/11/12.
//  Copyright © 2015年 Going. All rights reserved.
//

#import "ManyPeopleListenCollectionReusableView.h"

@interface ManyPeopleListenCollectionReusableView ()

//标题
@property(nonatomic, retain) UILabel *nameLabel;
//介绍
@property(nonatomic, retain) UILabel *descLabel;
//更多
@property(nonatomic, retain) UIButton *moreButton;
//横条
@property(nonatomic, retain) UILabel *lineLabel;
@end


@implementation ManyPeopleListenCollectionReusableView
- (void)dealloc {
    [_nameLabel release];
    [_descLabel release];
    [_moreButton release];
    [_lineLabel release];
    [_index release];
    [_manyPeopleListenModel release];
    [super dealloc];
}
- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        // 创建视图
        [self createSubView];
    }
    return self;
}
#pragma mark 创建视图
- (void)createSubView {
    
    //标签
    self.nameLabel = [[UILabel alloc]init];
//    self.nameLabel.backgroundColor = [UIColor redColor];
    self.nameLabel.textColor = [UIColor whiteColor];
    self.nameLabel.font = [UIFont systemFontOfSize:20];
    [self addSubview:self.nameLabel];
    [self.nameLabel release];
    
    //介绍
    self.descLabel = [[UILabel alloc]init];
//    self.descLabel.backgroundColor = [UIColor orangeColor];
    self.descLabel.font = [UIFont systemFontOfSize:14];
    self.descLabel.textColor = [UIColor colorWithRed:0.663 green:0.686 blue:0.686 alpha:1.000];
    [self addSubview:self.descLabel];
    [self.descLabel release];
    
    //更多
    self.moreButton = [UIButton buttonWithType:UIButtonTypeCustom];
//    self.moreButton.backgroundColor = [UIColor purpleColor];
    [self.moreButton setTitleColor:[UIColor colorWithRed:0.682 green:0.686 blue:0.686 alpha:1.000] forState:UIControlStateNormal];
    self.moreButton.titleLabel.font = [UIFont systemFontOfSize:15];
    [self.moreButton addTarget:self action:@selector(moreButtonAction:) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:self.moreButton];
    [self.moreButton release];
}
#pragma mark 重写manyPeopleListenModel的setter方法
- (void)setManyPeopleListenModel:(ManyPeopleListenModel *)manyPeopleListenModel {
    if (_manyPeopleListenModel != manyPeopleListenModel) {
        [_manyPeopleListenModel release];
        _manyPeopleListenModel = [manyPeopleListenModel retain];
    }
   //名称
    self.nameLabel.frame = CGRectMake(10, 10, 21 * manyPeopleListenModel.name.length, self.frame.size.height - 10);
     self.nameLabel.text = manyPeopleListenModel.name;
    //介绍
    self.descLabel.frame = CGRectMake(self.nameLabel.frame.size.width + self.nameLabel.frame.origin.x, self.nameLabel.frame.origin.y, 14 * manyPeopleListenModel.desc.length, self.nameLabel.frame.size.height);
    self.descLabel.text = manyPeopleListenModel.desc;
    //更多
    self.moreButton.frame = CGRectMake(self.frame.size.width - 70, self.descLabel.frame.origin.y, 50, self.descLabel.frame.size.height);
    [self.moreButton setTitle:@"更多>" forState:UIControlStateNormal];
}
#pragma mark 重写showDesc的setter方法
- (void)setShowDesc:(BOOL)showDesc {
    _showDesc = showDesc;
    if (showDesc == NO) {
        self.descLabel.frame = CGRectMake(0, 0, 0, 0);
    }
}
#pragma mark 重写showButton的setter的方法
- (void)setShowButton:(BOOL)showButton {
    _showButton = showButton;
    if (showButton == NO) {
        self.moreButton.frame = CGRectMake(0, 0, 0, 0);
    }
}
- (void)moreButtonAction:(UIButton *)button {
    [self.delegate moreButtonClickedAction:self.index];
}
@end
